package com.neulogistics.contrib.warehouse.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 出入库单表
 * @TableName tb_circulation_order
 */
@TableName(value ="tb_circulation_order", autoResultMap = true)
@Data
public class CirculationOrderPO implements Serializable {
    /**
     * 出入库单id
     */
    @TableId(value = "circulation_id")
    private Long circulationId;

    /**
     * 所属库房id
     */
    @TableField(value = "warehouse_id")
    private Integer warehouseId;

    /**
     * 流动类型: 0:入库；1:出库
     */
    @TableField(value = "circulation_type")
    private Integer circulationType;

    /**
     * 流动细节: 0:进货入库；1:调拨入库；2:退货入库；3:调拨出库；4:退货出库；5:取货出库
     */
    @TableField(value = "circulation_detail")
    private Integer circulationDetail;

    /**
     * 调拨单id
     */
    @TableField(value = "transfer_id")
    private Long transferId;

    /**
     * 任务id
     */
    @TableField(value = "task_id")
    private Long taskId;

    /**
     * 货物数组[{商品id、计量单位、数量}]
     */
    @TableField(value = "goods_items", typeHandler = JacksonTypeHandler.class)
    private JSONArray goodsItems;

    /**
     * 状态: 0:进行中；1:已完成；2:已取消
     */
    @TableField(value = "circulation_status")
    private Integer circulationStatus;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 完成时间
     */
    @TableField(value = "complete_time")
    private Date completeTime;

    /**
     * 最后操作人
     */
    @TableField(value = "last_operator")
    private Integer lastOperator;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CirculationOrderPO other = (CirculationOrderPO) that;
        return (this.getCirculationId() == null ? other.getCirculationId() == null : this.getCirculationId().equals(other.getCirculationId()))
            && (this.getWarehouseId() == null ? other.getWarehouseId() == null : this.getWarehouseId().equals(other.getWarehouseId()))
            && (this.getCirculationType() == null ? other.getCirculationType() == null : this.getCirculationType().equals(other.getCirculationType()))
            && (this.getCirculationDetail() == null ? other.getCirculationDetail() == null : this.getCirculationDetail().equals(other.getCirculationDetail()))
            && (this.getTransferId() == null ? other.getTransferId() == null : this.getTransferId().equals(other.getTransferId()))
            && (this.getTaskId() == null ? other.getTaskId() == null : this.getTaskId().equals(other.getTaskId()))
            && (this.getGoodsItems() == null ? other.getGoodsItems() == null : this.getGoodsItems().equals(other.getGoodsItems()))
            && (this.getCirculationStatus() == null ? other.getCirculationStatus() == null : this.getCirculationStatus().equals(other.getCirculationStatus()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getCompleteTime() == null ? other.getCompleteTime() == null : this.getCompleteTime().equals(other.getCompleteTime()))
            && (this.getLastOperator() == null ? other.getLastOperator() == null : this.getLastOperator().equals(other.getLastOperator()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.getCirculationId() == null) ? 0 : this.getCirculationId().hashCode());
        result = prime * result + ((getWarehouseId() == null) ? 0 : getWarehouseId().hashCode());
        result = prime * result + ((getCirculationType() == null) ? 0 : getCirculationType().hashCode());
        result = prime * result + ((getCirculationDetail() == null) ? 0 : getCirculationDetail().hashCode());
        result = prime * result + ((getTransferId() == null) ? 0 : getTransferId().hashCode());
        result = prime * result + ((getTaskId() == null) ? 0 : getTaskId().hashCode());
        result = prime * result + ((this.getGoodsItems() == null) ? 0 : this.getGoodsItems().hashCode());
        result = prime * result + ((getCirculationStatus() == null) ? 0 : getCirculationStatus().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getCompleteTime() == null) ? 0 : getCompleteTime().hashCode());
        result = prime * result + ((getLastOperator() == null) ? 0 : getLastOperator().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", circulationId=").append(circulationId);
        sb.append(", warehouseId=").append(warehouseId);
        sb.append(", circulationType=").append(circulationType);
        sb.append(", circulationDetail=").append(circulationDetail);
        sb.append(", transferId=").append(transferId);
        sb.append(", taskId=").append(taskId);
        sb.append(", goodsItem=").append(goodsItems);
        sb.append(", circulationStatus=").append(circulationStatus);
        sb.append(", createTime=").append(createTime);
        sb.append(", completeTime=").append(completeTime);
        sb.append(", lastOperator=").append(lastOperator);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}